﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WaterRevenueMS.Domain.Common.Models;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace WaterRevenueMS.Domain.ViewModels.BasicSet.WayOfCharge
{
    public class WayOfChargeModel : EntityCommon
    {
        public WayOfChargeModel()
        {
            OrderNo = 0;
            Shou_FLX = 0;
            Shou_FYF = 0;
            Shou_FRQ = 28;
            TypeItems = new List<SelectListItem>
            {
                new SelectListItem{Text="后付费",Value="0"},
                new SelectListItem{Text="预付费",Value="1"}
            };

            ChargeWayItems = new List<SelectListItem>
            {   
                new SelectListItem{Text="入账收费",Value="0"},
                new SelectListItem{Text="当月收费",Value="1"},
                new SelectListItem{Text="次月收费",Value="2"}
            };
            Search = new SearchModel();
        }

        public int Id { get; set; }
        [Display(Name = "收费方式名称")]
        [Required(ErrorMessage = "方式名不能为空")]
        [StringLength(16, ErrorMessage = "方式名称不能大于{1}个字符")]
        public string Shou_FFS { get; set; }

        public byte DefaultValue { get; set; }

        [Display(Name = "排序序号")]
        public int OrderNo { get; set; }

        [Display(Name = "收费类型")]
        public byte Shou_FLX { get; set; }
        public List<SelectListItem> TypeItems { get; set; }

        [Display(Name = "收费月份")]
        public byte Shou_FYF { get; set; }
        public List<SelectListItem> ChargeWayItems { get; set; }

        [Display(Name = "每月收费日期(1-31)")]
        [RegularExpression(@"^\+?[0-2][0-9]*$", ErrorMessage = "收费日期错误")]
        public byte Shou_FRQ { get; set; }

        public SearchModel Search { get; set; }
        public string Shou_FLX_HZ
        {
            get
            {
                if (Shou_FLX == 0)
                {
                    return "后付费";
                }
                else
                {
                    return "预付费";
                }

            }
            set { }
        }

        public string Shou_FYF_HZ
        {
            get
            {
                if (Shou_FYF == 0)
                {
                    return "入账收费";
                }
                else
                {
                    if (Shou_FYF == 1)
                    {
                        return "当月收费";
                    }
                    else
                    {
                        return "次月收费";
                    }
                }

            }
            set { }
        }
    }
    public class SearchModel
    {
        public SearchModel()
        {

        }

        [Display(Name = "收费方式名称")]
        public string Shou_FFS { get; set; }
    }
}
